﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "Quản lý mẫu email";
}

<form class="form" action="##">
<div id="apps" class="content">
	<h2 class="app">        
		<span class="viewtitle"><strong>Quản lý email</strong> <a href="javascript:void(0)" class="info" title="Quản lý mẫu email"><em>info</em></a></span>
        <span class="right"><a href="/EmailTemplate/Add">Thêm mới &raquo;</a></span>
        
	</h2>                
    <div class="title nomargin">
        <span class="right-btns">
            <input id="q" type="text" class="text spl search filter" data-bind="event: { keypress: RunSomethingKey }" autocomplete="off" placeholder="Từ khóa" />
            <span class="v-line"></span>
            <a href="javascript:void(0)" class="btn btn-go" data-bind="click: SearchButton">Go</a>
        </span>
        <h3>Xem danh mục</h3>
    </div>
    <span class="paging" data-bind="visible: ItemList().length>0">
        <span class="pageleft">
            <span class="total" data-bind='text: PageText'></span>
            <span class="show">Hiển thị <input type="text" class="text" id="PageSize" data-bind="value: PageSize" onkeypress="return isNumberKey(event)" /> trên trang <span class="smallText" data-bind="text: PageSizeText"></span></span>
        </span>
        <span class="pages">
            <span class="smallText" data-bind="text: PageIndexText, visible: ItemList().length>0"></span> 
            Trang <input type="text" class="text" id="PageIndex" data-bind="value: PageIndex" onkeypress="return isNumberKey(event)" /> của <span data-bind="text: TotalPage"></span>
            <a href="javascript:void(0)" class="btn btn-prev-arrow" data-bind="click: PrevButton, attr: {'class': PrevButtonClass}"></a>                            
            <a href="javascript:void(0)" class="btn btn-next-arrow" data-bind="click: NextButton, attr: {'class': NextButtonClass}"></a>
        </span>
    </span>
    <div class="linegroup" data-bind="visible: ItemList().length>0">        
        <table class="tablegrid" cellspacing="0" border="0">
            <thead>
                <tr class="title">        
		            <th>
                        <span class="w">
                            <a href="javascript:void(0)" data-bind='click: function(event) { SetOrder(event, "Subject")}'>Tiêu đề</a>
                            <div class="sort_wrapper" id="Subject">  
                                <span class="grid_order ui_icon"></span>
                            </div>               
                        </span>
                    </th>
                    <th>
                        <span class="w">
                            <a href="javascript:void(0)" data-bind='click: function(event) { SetOrder(event, "FromEmail")}'>Gửi từ Email</a>
                            <div class="sort_wrapper" id="FromEmail">  
                                <span class="grid_order ui_icon"></span>
                            </div>               
                        </span>
                    </th>
                     <th>
                        <span class="w">
                            <span class="w">Cho phép html</span>
                            <div class="sort_wrapper" id="IsBodyHtml">  
                                <span class="grid_order ui_icon"></span>
                            </div>               
                        </span>
                    </th>
		            <th class="last centeralign"><span class="w">Xóa</span></th>
                </tr>
            </thead>
            <tbody data-bind="foreach: ItemList">
                <tr class="line">
                     <td>
                        <span class="w">
                            <a data-bind='text:Subject, attr: {href: "/EmailTemplate/Edit/" + TemplateId, title:Subject}'>Edit</a>
                        </span>
                    </td>
                    <td><span class="w" data-bind="text:FromEmail"></span></td>
                    <td class="active"><span class="w" data-bind="text:IsBodyHtml?'Có':'không'"></span></td>

                    <td class="last centeralign">
                        <span class="w">
                            <a class="btn btn-edit edit" href="javascript:void(0)" data-bind="attr:{href: '/EmailTemplate/Edit/' +TemplateId}">Edit</a>
                            <a class="btn btn-x delete" href="javascript:void(0)" data-bind='click:$parent.DeleteItems'>Delete</a>
                        </span>
                    </td>
	            </tr>
            </tbody>
        </table>
        @Html.Partial("PopupDelete")
    </div>
    <div class="panel" data-bind="visible: ItemList().length<=0" style="display:none">
        <div class="error-msg" ><span>Không kết quả nào được tìm thấy.</span></div>                        
    </div>  
</div>
</form>

<script type="text/javascript">
//<![CDATA[
    var data = @(Html.Raw(Json.Encode(Model)));

    $(document).ready(function() {
        $(".paging input")
            .removeClass("text-active")
            .focus(function() { $(this).addClass("text-active"); })
            .blur(function() { $(this).removeClass("text-active"); });
    });

    
//]]>
</script>

<script src="/Scripts/EmailTemplate/EmailTemplateGrid.js" type="text/javascript"></script>
